from bs4 import BeautifulSoup
import requests

kw = {'wd':'女神异闻录'}

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) \
    Chrome/54.0.2840.99 Safari/537.36"}

response = requests.get("http://www.baidu.com/s?", params = kw, headers = headers)

soup = BeautifulSoup(response.text, 'lxml')

# print(soup.prettify())          # 输出所有内容

a_list = soup.find_all('a')
for element in a_list:
    print(element.text)
    print(element.attrs['href'])